<template>
  <div>
    <el-input :model-value="modelValue" placeholder="请输入内容" :disabled="disabled" @update:model-value="updateValue">
      <template #append>
        <el-button @click="handleClipboard(modelValue, $event)">复制</el-button>
      </template>
    </el-input>
  </div>
</template>

<script>
import handleClipboard from '@/utils/clipboard'

export default {
  name: 'DkCopyInput',
  props: {
    modelValue: {
      default: '',
      type: String
    },
    successText: {
      default: '复制成功',
      type: String
    },
    disabled: {
      default: false,
      type: Boolean
    }
  },
  emits: ['update:modelValue'],
  data() {
    return {}
  },
  computed: {},
  mounted() {},
  methods: {
    updateValue(value) {
      this.$emit('update:modelValue', value)
    },
    handleClipboard(text, event) {
      handleClipboard(text, event, this.successText)
    }
  }
}
</script>

<style scoped lang="scss"></style>
